package tankgame6;

import javax.swing.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.Scanner;

@SuppressWarnings("all")
public class HspTankGame06 extends JFrame {
    /**
     * 定义全局变量
     */
    MyPanel my = null;

    public static void main(String[] args) {
        HspTankGame06 hspTankGame02 = new HspTankGame06();
    }

    /**
     * 构造函数
     */
    public HspTankGame06() {
        Scanner scanner = new Scanner(System.in);
        System.out.println("1：新游戏  2：继续上局游戏");
        String key = scanner.next();

//        my = new MyPanel("1");
        my = new MyPanel(key);
        new Thread(my).start(); //一直更新画面，一直判断子弹，坦克该不该画以及怎么画

        this.add(my);//把面板加到
        this.setSize(1000, 700);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setVisible(true);
        this.addKeyListener(my);
        //点击右上角关闭按钮，该方法会执行，程序再关闭
        this.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
                Recorder.keepRecord();
            }

        });
    }
}
